﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MainMaster.master" AutoEventWireup="true"
    CodeFile="EditPromotionDetail.aspx.cs" Inherits="PromotionInfo_EditPromotionDetail"
    CodeFileBaseClass="Frame.Pages.ActionInfomationEditBasePage" %>

<%@ Register Assembly="DevExpress.Web.v10.2, Version=10.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxRoundPanel" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v10.2.Linq, Version=10.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Data.Linq" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v10.2, Version=10.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v10.2, Version=10.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxCallbackPanel" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v10.2, Version=10.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v10.2, Version=10.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v10.2, Version=10.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxPanel" TagPrefix="dx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <link href="../Css/table.css" rel="stylesheet" type="text/css" />
    <script language="javascript" type="text/javascript">
        //显示选中的商品
        function GetPro(id) {
            prolist.SelectAllRowsOnPage(false);
            //labcxbm.SetText(id);
            $.ajax({
                type: "Post",
                url: "EditPromotionDetail.aspx/GetPros",
                data: "{'cxbh': '" + id + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    for (var i = 0; i < data.d.length; i++) {
                        if (data.d[i] != null) {
                            prolist.SelectRowsByKey(data.d[i]);
                        }
                    }

                },
                error: function (err) {
                    //alert("关联人员获取失败,请重试！");
                    noty({ "text": "关联人员获取失败,请重试！",
                        "layout": "top",
                        "type": "error",
                        "animateOpen": { "height": "toggle" },
                        "animateClose": { "height": "toggle" },
                        "speed": 500,
                        "timeout": 1000,
                        "closeButton": false,
                        "closeOnSelfClick": true,
                        "closeOnSelfOver": false
                    });
                }
            });
        }
        //显示商品信息
        function ShowProduct() {
            if (pupProShow.IsWindowVisible()) {
                //alert("保存成功！");
                noty({ "text": "商品保存成功！",
                    "layout": "top",
                    "type": "success",
                    "animateOpen": { "height": "toggle" },
                    "animateClose": { "height": "toggle" },
                    "speed": 500,
                    "timeout": 1000,
                    "closeButton": false,
                    "closeOnSelfClick": true,
                    "closeOnSelfOver": false
                });
                pupProShow.Hide()
            }
            else {
                pupProShow.Show();
            }
            // pupProShow.Show();
        }
        //选择商品
        function gridPro_SelectionChanged(s, e) {
            s.GetSelectedFieldValues("spbm;spmc", GetSelectedFieldValuesCallbackS);
        }
        function GetSelectedFieldValuesCallbackS(values) {
            if (values != "") {
                labProid.SetText(values[0][0]);
                labProname.SetText(values[0][1]);
                //                cspbm.SetText(values[0][0]);
                //                cspmc.SetText(values[0][1]);
            }
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" runat="server" ContentPlaceHolderID="MainContent">
    <dx:ASPxRoundPanel ID="MainRoundPanel" runat="server" Width="100%" CssFilePath="~/App_Themes/Office2010Blue/{0}/styles.css"
        CssPostfix="Office2010Blue" EnableDefaultAppearance="False" GroupBoxCaptionOffsetX="6px"
        GroupBoxCaptionOffsetY="-19px" SpriteCssFilePath="~/App_Themes/Office2010Blue/{0}/sprite.css">
        <ContentPaddings PaddingBottom="10px" PaddingLeft="9px" PaddingRight="11px" PaddingTop="10px" />
        <HeaderStyle>
            <Paddings PaddingBottom="6px" PaddingLeft="9px" PaddingRight="11px" PaddingTop="3px" />
        </HeaderStyle>
        <PanelCollection>
            <dx:PanelContent runat="server" SupportsDisabledAttribute="True">
            </dx:PanelContent>
        </PanelCollection>
    </dx:ASPxRoundPanel>
    <h1 class="DemoTitle">
        促销详细信息管理
    </h1>
    <div id="DemoArea">
        <a href="EditPromotion.aspx">
            <h3>
                返回促销信息管理页</h3>
        </a>
        <dx:ASPxGridView ID="gridView" runat="server" Width="100%" AutoGenerateColumns="False"
            ClientInstanceName="datalist" KeyFieldName="jlxh" CssFilePath="~/App_Themes/Office2010Blue/{0}/styles.css"
            CssPostfix="Office2010Blue" DataSourceID="LSMDSourceMainProPromotionDetail" OnRowInserting="gridView_RowInserting"
            OnRowUpdating="gridView_RowUpdating" OnCellEditorInitialize="gridView_CellEditorInitialize">
            <Columns>
                <dx:GridViewDataTextColumn Caption="促销编号" FieldName="cxbh" Name="t_cxbh" ShowInCustomizationForm="True"
                    VisibleIndex="0">
                    <EditFormSettings Visible="False" />
                    <CellStyle HorizontalAlign="Left">
                    </CellStyle>
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn Caption="记录序号" FieldName="jlxh" Name="t_jlxh" ShowInCustomizationForm="True"
                    VisibleIndex="1" ReadOnly="True" Visible="False">
                    <CellStyle HorizontalAlign="Left">
                    </CellStyle>
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataComboBoxColumn Caption="商品名称" FieldName="spbm" Name="t_spbms" VisibleIndex="1">
                    <PropertiesComboBox Spacing="0" ValueType="System.String">
                    </PropertiesComboBox>
                    <EditFormSettings Visible="False" />
                </dx:GridViewDataComboBoxColumn>
                <dx:GridViewDataComboBoxColumn Caption="选择商品" Name="t_spbm" ShowInCustomizationForm="True"
                    VisibleIndex="2">
                    <PropertiesComboBox Spacing="0" ValueType="System.String">
                    </PropertiesComboBox>
                    <EditFormSettings CaptionLocation="Near" Visible="False" />
                    <DataItemTemplate>
                        <a href="javascript:GetPro(' <%# Eval("cxbh")%> ');ShowProduct();">选择商品</a>
                    </DataItemTemplate>
                    <CellStyle HorizontalAlign="Left">
                    </CellStyle>
                </dx:GridViewDataComboBoxColumn>
                <dx:GridViewDataComboBoxColumn Caption="是否赠卷" FieldName="flag_zq" Name="t_flag_zq"
                    ShowInCustomizationForm="True" VisibleIndex="3">
                    <PropertiesComboBox Spacing="0" ValueType="System.String">
                        <Items>
                            <dx:ListEditItem ImageUrl="~/Images/icon/A.png" Text="是" Value="Y" />
                            <dx:ListEditItem ImageUrl="~/Images/icon/Cancel.png" Text="否" Value="N" />
                        </Items>
                    </PropertiesComboBox>
                    <CellStyle HorizontalAlign="Left">
                    </CellStyle>
                </dx:GridViewDataComboBoxColumn>
                <dx:GridViewDataComboBoxColumn Caption="是否收卷" FieldName="flag_sq" Name="t_falg_sq"
                    ShowInCustomizationForm="True" VisibleIndex="4">
                    <PropertiesComboBox Spacing="0" ValueType="System.String">
                        <Items>
                            <dx:ListEditItem ImageUrl="~/Images/icon/A.png" Text="是" Value="Y" />
                            <dx:ListEditItem ImageUrl="~/Images/icon/Cancel.png" Text="否" Value="N" />
                        </Items>
                    </PropertiesComboBox>
                    <CellStyle HorizontalAlign="Left">
                    </CellStyle>
                </dx:GridViewDataComboBoxColumn>
                <dx:GridViewDataComboBoxColumn Caption="是否生效" FieldName="flag" Name="t_flag" ShowInCustomizationForm="True"
                    VisibleIndex="5">
                    <PropertiesComboBox Spacing="0" ValueType="System.String">
                        <Items>
                            <dx:ListEditItem ImageUrl="~/Images/icon/A.png" Text="是" Value="Y" />
                            <dx:ListEditItem ImageUrl="~/Images/icon/Cancel.png" Text="否" Value="N" />
                        </Items>
                    </PropertiesComboBox>
                    <EditFormSettings Visible="False" />
                    <CellStyle HorizontalAlign="Left">
                    </CellStyle>
                </dx:GridViewDataComboBoxColumn>
                <dx:GridViewDataTimeEditColumn Caption="生效日期" FieldName="sxrq" Name="t_sxrq" Visible="False"
                    VisibleIndex="6">
                    <PropertiesTimeEdit DisplayFormatString="g" EditFormat="DateTime" Spacing="0">
                    </PropertiesTimeEdit>
                    <EditFormSettings Visible="False" />
                    <CellStyle HorizontalAlign="Left">
                    </CellStyle>
                </dx:GridViewDataTimeEditColumn>
                <dx:GridViewDataTextColumn Caption="取消日期" FieldName="qxrq" Name="t_qxrq" ShowInCustomizationForm="True"
                    VisibleIndex="7" Visible="False">
                    <EditFormSettings Visible="False" />
                    <CellStyle HorizontalAlign="Left">
                    </CellStyle>
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataMemoColumn Caption="备注" FieldName="bz" Name="t_bz" ShowInCustomizationForm="True"
                    VisibleIndex="8" Visible="False">
                    <PropertiesMemoEdit Height="80px">
                    </PropertiesMemoEdit>
                    <EditFormSettings ColumnSpan="2" Visible="True" />
                    <CellStyle HorizontalAlign="Left">
                    </CellStyle>
                </dx:GridViewDataMemoColumn>
                <dx:GridViewDataTextColumn Caption="创建者" FieldName="founder" Name="t_founder" ShowInCustomizationForm="True"
                    Visible="False" VisibleIndex="9">
                    <EditFormSettings Visible="False" />
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn Caption="创建日期" FieldName="fdate" Name="t_fdate" ShowInCustomizationForm="True"
                    Visible="False" VisibleIndex="10">
                    <EditFormSettings Visible="False" />
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn Caption="最后修订人" FieldName="editor" Name="t_deitor" ShowInCustomizationForm="True"
                    Visible="False" VisibleIndex="11">
                    <EditFormSettings Visible="False" />
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn Caption="最后修订日期" FieldName="edate" Name="t_edate" ShowInCustomizationForm="True"
                    Visible="False" VisibleIndex="13">
                    <EditFormSettings Visible="False" />
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn Caption="是否生效" VisibleIndex="12" Width="100px" Name="t_flag">
                    <EditFormSettings Visible="False" />
                    <DataItemTemplate>
                        <div style="float: left;">
                            <dx:ASPxButton ID="btnSxD" runat="server" Text="生效" CssFilePath="~/App_Themes/Office2003Olive/{0}/styles.css"
                                CssPostfix="Office2003Olive" OnClick="btnSxD_Click" SpriteCssFilePath="~/App_Themes/Office2003Olive/{0}/sprite.css">
                                <%--   <ClientSideEvents Click="function(s,e){pupShows.Hide();}" />--%>
                            </dx:ASPxButton>
                        </div>
                        <div style="float: left;">
                            <dx:ASPxButton ID="btnQxD" runat="server" Text="取消" CssFilePath="~/App_Themes/Office2003Olive/{0}/styles.css"
                                CssPostfix="Office2003Olive" OnClick="btnQxD_Click" SpriteCssFilePath="~/App_Themes/Office2003Olive/{0}/sprite.css">
                            </dx:ASPxButton>
                        </div>
                    </DataItemTemplate>
                </dx:GridViewDataTextColumn>
            </Columns>
            <SettingsBehavior AllowDragDrop="False" ConfirmDelete="True" AllowFocusedRow="True" />
            <SettingsEditing Mode="PopupEditForm" PopupEditFormHorizontalAlign="Center" PopupEditFormModal="True"
                PopupEditFormVerticalAlign="WindowCenter" PopupEditFormWidth="600px" />
            <Settings ShowFilterRow="true" ShowGroupPanel="false" />
            <SettingsDetail ShowDetailRow="True" />
            <%--  <ClientSideEvents EndCallback="ShowProduct" />--%>
            <Images SpriteCssFilePath="~/App_Themes/Office2010Blue/{0}/sprite.css">
                <LoadingPanelOnStatusBar Url="~/App_Themes/Office2010Blue/GridView/Loading.gif">
                </LoadingPanelOnStatusBar>
                <LoadingPanel Url="~/App_Themes/Office2010Blue/GridView/Loading.gif">
                </LoadingPanel>
            </Images>
            <ImagesFilterControl>
                <LoadingPanel Url="~/App_Themes/Office2010Blue/GridView/Loading.gif">
                </LoadingPanel>
            </ImagesFilterControl>
            <Styles CssFilePath="~/App_Themes/Office2010Blue/{0}/styles.css" CssPostfix="Office2010Blue">
                <Header ImageSpacing="5px" SortingImageSpacing="5px">
                </Header>
                <LoadingPanel ImageSpacing="5px">
                </LoadingPanel>
            </Styles>
            <StylesPager>
                <PageNumber ForeColor="#3E4846">
                </PageNumber>
                <Summary ForeColor="#1E395B">
                </Summary>
            </StylesPager>
            <StylesEditors ButtonEditCellSpacing="0">
            </StylesEditors>
            <Templates>
                <DetailRow>
                    <table style="font-size: 10pt" width="600px">
                        <tr style="height:30px">
                            <td  class="t1">
                                备注:
                            </td>
                            <td class="t2" colspan="3" style="text-indent:2em;">
                                <dx:ASPxLabel Width="200px" Font-Size="10pt" ID="View_qyxz" Wrap="true" runat="server"
                                    CssFilePath="~/App_Themes/DevEx/{0}/styles.css" Text='<%# Eval("bz") %>' CssPostfix="DevEx">
                                </dx:ASPxLabel>
                            </td>
                        </tr>
                        <tr>
                            <td  class="t1">
                                生效日期:
                            </td>
                            <td class="t2">
                                <dx:ASPxLabel Width="200px" Font-Size="10pt" ID="ASPxLabel1" Wrap="true" runat="server"
                                    CssFilePath="~/App_Themes/DevEx/{0}/styles.css" Text='<%# Eval("sxrq") %>' CssPostfix="DevEx">
                                </dx:ASPxLabel>
                            </td>
                            <td  class="t1">
                                取消日期:
                            </td>
                            <td class="t2">
                                <dx:ASPxLabel Width="200px" Font-Size="10pt" ID="ASPxLabel2" Wrap="true" runat="server"
                                    CssFilePath="~/App_Themes/DevEx/{0}/styles.css" Text='<%# Eval("qxrq") %>' CssPostfix="DevEx">
                                </dx:ASPxLabel>
                            </td>
                        </tr>
                    </table>
                </DetailRow>
            </Templates>
        </dx:ASPxGridView>
        <dx:ASPxPopupControl ID="ASPxPopupControl1" runat="server" ClientInstanceName="pupProShow"
            Width="450px" CssFilePath="~/App_Themes/Office2010Blue/{0}/styles.css" CssPostfix="Office2010Blue"
            EnableHotTrack="False" HeaderText="选择商品信息" SpriteCssFilePath="~/App_Themes/Office2010Blue/{0}/sprite.css"
            Modal="True" PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter">
            <ContentCollection>
                <dx:PopupControlContentControl ID="PopupControlContentControl1" runat="server" SupportsDisabledAttribute="True">
                    <table>
                        <tr>
                            <td>
                                商品编码：
                            </td>
                            <td>
                                <dx:ASPxLabel ID="labProid" runat="server" ClientInstanceName="labProid" Text="">
                                </dx:ASPxLabel>
                            </td>
                            <td>
                                商品名称：
                            </td>
                            <td>
                                <dx:ASPxLabel ID="labProname" runat="server" ClientInstanceName="labProname" Text="">
                                </dx:ASPxLabel>
                            </td>
                        </tr>
                    </table>
                    <dx:ASPxGridView ID="ShowProduct" runat="server" ClientInstanceName="prolist" KeyFieldName="spbm"
                        Width="100%" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" CssFilePath="~/App_Themes/Office2010Blue/{0}/styles.css"
                        CssPostfix="Office2010Blue" OnCustomCallback="ShowProduct_CustomCallback">
                        <ClientSideEvents SelectionChanged="gridPro_SelectionChanged" />
                        <%--   <ClientSideEvents EndCallback="ShowProduct" />--%>
                        <Columns>
                            <dx:GridViewCommandColumn ShowInCustomizationForm="True" ShowSelectCheckbox="True"
                                VisibleIndex="0" Width="10px">
                                <ClearFilterButton Visible="True">
                                </ClearFilterButton>
                            </dx:GridViewCommandColumn>
                            <dx:GridViewDataTextColumn FieldName="spbm" ReadOnly="True" ShowInCustomizationForm="True"
                                VisibleIndex="0" Settings-AllowAutoFilter="False" Caption="商品编码">
                                <Settings AllowAutoFilter="False"></Settings>
                                <CellStyle HorizontalAlign="Left">
                                </CellStyle>
                            </dx:GridViewDataTextColumn>
                            <dx:GridViewDataTextColumn FieldName="spmc" ShowInCustomizationForm="True" VisibleIndex="1"
                                Caption="商品名称">
                                <CellStyle HorizontalAlign="Left">
                                </CellStyle>
                            </dx:GridViewDataTextColumn>
                        </Columns>
                        <SettingsBehavior AllowSelectSingleRowOnly="true" />
                        <Settings ShowFilterRow="True" />
                        <SettingsText EmptyDataRow="没有记录" />
                        <Images SpriteCssFilePath="~/App_Themes/Office2010Blue/{0}/sprite.css">
                            <LoadingPanelOnStatusBar Url="~/App_Themes/Office2010Blue/GridView/Loading.gif">
                            </LoadingPanelOnStatusBar>
                            <LoadingPanel Url="~/App_Themes/Office2010Blue/GridView/Loading.gif">
                            </LoadingPanel>
                        </Images>
                        <ImagesFilterControl>
                            <LoadingPanel Url="~/App_Themes/Office2010Blue/GridView/Loading.gif">
                            </LoadingPanel>
                        </ImagesFilterControl>
                        <Styles CssFilePath="~/App_Themes/Office2010Blue/{0}/styles.css" CssPostfix="Office2010Blue">
                            <Header ImageSpacing="5px" SortingImageSpacing="5px">
                            </Header>
                            <LoadingPanel ImageSpacing="5px">
                            </LoadingPanel>
                        </Styles>
                        <StylesPager>
                            <PageNumber ForeColor="#3E4846">
                            </PageNumber>
                            <Summary ForeColor="#1E395B">
                            </Summary>
                        </StylesPager>
                        <StylesEditors ButtonEditCellSpacing="0">
                            <ProgressBar Height="21px">
                            </ProgressBar>
                        </StylesEditors>
                    </dx:ASPxGridView>
                    <table width="100%">
                        <tr>
                            <td align="right">
                                <dx:ASPxButton ID="BtnSave" runat="server" Text="保存" CssFilePath="~/App_Themes/Office2010Blue/{0}/styles.css"
                                    CssPostfix="Office2010Blue" SpriteCssFilePath="~/App_Themes/Office2010Blue/{0}/sprite.css"
                                    AutoPostBack="False" UseSubmitBehavior="False">
                                    <ClientSideEvents Click="function(s,e){prolist.PerformCallback(labProid.GetValue()); ShowProduct();}" />
                                    <ClientSideEvents Click="function(s,e){prolist.PerformCallback(labProid.GetValue());ShowProduct(); }">
                                    </ClientSideEvents>
                                </dx:ASPxButton>
                            </td>
                        </tr>
                    </table>
                </dx:PopupControlContentControl>
            </ContentCollection>
        </dx:ASPxPopupControl>
        <dx:LinqServerModeDataSource ID="LSMDSourceMainProPromotionDetail" runat="server"
            ContextTypeName="DAL.DataClassesDataContext" EnableDelete="True" EnableInsert="True"
            EnableUpdate="True" OnSelecting="LSMDSourceMainProPromotionDetail_Selecting"
            TableName="css_sp_mjms_mx" />
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:CMSConnectionString %>"
            SelectCommand="SELECT [spbm], [spmc] FROM [css_spjbxx]"></asp:SqlDataSource>
    </div>
</asp:Content>
